<template>
	<view style="display: flex; flex-direction: column">
		<view>
			<view style="color: #000; font-size: 30rpx; text-align: center; margin: 20rpx 60rpx 0 60rpx">{{ detail.title }}</view>
			<view style="color: #999; font-size: 24rpx; text-align: center; margin: 10rpx 60rpx 0 60rpx">{{ detail.createtime }}</view>
		</view>
		<rich-text style="color: #222; font-size: 26rpx; margin: 30rpx 60rpx 0 60rpx" :nodes="detail.content"></rich-text>
	</view>
</template>

<script>
	const app = getApp() // 获取应用实例
	const util = require('../../../utils/util');
	import { reqNewsDetail, reqPrivacy } from '../../../utils/http/api'
	export default {
		data() {
			return {
				// 传过来的id
				id: '',
				// 页面详情
				detail: { title: '', createtime: '', content: '' }
			}
		},
		onLoad: function(options) {
			this.setData({ id: options.id })
			if (options.type == '99') {
				// 用户协议和隐私政策
				this.reqPrivacy()
			} else {
				this.reqNewsDetail()
			}
		},
		// 用户点击右上角分享
		onShareAppMessage: function() {},
		methods: {
			// 公告、招商详情
			async reqNewsDetail() {
				uni.showLoading({ title: '加载中', mask: true })
				let { code, msg, data } = await reqNewsDetail({ id: this.id })
				if (code == '1') {
					this.setData({ detail: data })
					uni.setNavigationBarTitle({ title: this.detail.title })
				} else {
					uni.showToast({ title: msg, icon: 'none' })
				}
			},

			// 用户协议,隐私政策详情
			async reqPrivacy() {
				uni.showLoading({ title: '加载中', mask: true })
				let { code, msg, data } = await reqPrivacy({ id: this.id })
				if (code == '1') {
					this.setData({ detail: data })
					uni.setNavigationBarTitle({ title: this.detail.title })
				} else {
					uni.showToast({ title: msg, icon: 'none' })
				}
			}
		}
	};
</script>
<style scoped>
</style>